package com.xu.mall.framework.dao;

import java.io.Serializable;
import java.util.Map;

import com.xu.mall.framework.model.Pager;

public interface IBaseDao<T extends Serializable> {
	public static final String SUFFIX_INSERT = ".insert";
	public static final String SUFFIX_UPDATE = ".update";
	public static final String SUFFIX_DELETE = ".delete";
	public static final String SUFFIX_DELETE_BY_ID = ".deleteById";
	public static final String SUFFIX_GET_BY_ID = ".getById";
	public static final String SUFFIX_FIND = ".find";
	public static final String SUFFIX_COUNT = ".count";

	/**
	 * 新增对象
	 * 
	 * @param obj
	 * @return
	 */
	public int add(T obj);

	/**
	 * 删除对象
	 * 
	 * @param obj
	 * @return
	 */
	public int delete(Serializable id);

	/**
	 * 更新对象
	 * 
	 * @param obj
	 * @return
	 */
	public int update(T obj);

	/**
	 * 根据ID获取对象
	 * 
	 * @param clz
	 * @param id
	 * @return
	 */
	public T get(Serializable id);

	/**
	 * 分页查询
	 * 
	 * @param params
	 * @return
	 */
	public Pager<T> find(Map<String, Object> params);

	/**
	 * 分页查询，通过sqlId
	 * 
	 * @param sqlId
	 * @param params
	 * @return
	 */
	public Pager<T> find(String sqlId, Map<String, Object> params);

	/**
	 * 分页查询，通过sqlId
	 * 
	 * @param sqlId
	 * @param params
	 * @param startIndex
	 * @param pageSize
	 * @return
	 */
	public Pager<T> find(String sqlId, Map<String, Object> params, int startIndex, int pageSize);
}